package com.demo.config.websocket;

import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author admin &#064;class：WebSocketController &#064;since: 2023/9/20 9:01
 * &#064;description:
 */
@RestController
@RequestMapping("/websocket")
public class WebSocketController {

	@Resource
	private WebSocket webSocket;

	@RequestMapping("/send/{userId}")
	public void send(@PathVariable String userId) {
		// 全体发送
		// WebSocket.sendAllMessage("消息来了3333333333333333");
		// 单个用户发送 (userId为用户id)
		webSocket.sendOneMessage(userId, "消息来了2222222222222");
		// 多个用户发送 (userIds为多个用户id，逗号‘,’分隔)
		// webSocket.sendMoreMessage(userIds, obj.toJSONString());

	}

}
